﻿using System;

namespace Combinations
{
    class Combinations
    {
        static void PrintResult(int[] array)
        {
            foreach (int number in array)
            {
                Console.Write("{0} ", number);
            }
            Console.WriteLine();
        }

        static void GenerateCombinations(int[] array, int n, int k, int start)
        {
            if (k == array.Length)
            {
                PrintResult(array);
            }
            else
            {
                for (int i = start; i <= n; i++)
                {
                    array[k] = i;
                    GenerateCombinations(array, n, k + 1, i + 1);
                }
            }

        }

        static void Main()
        {
            Console.Write("Enter an integer for N: ");
            int n = int.Parse(Console.ReadLine());

            Console.Write("Enter an integer for K: ");
            int k = int.Parse(Console.ReadLine());

            int[] array = new int[k];

            GenerateCombinations(array, 0, n, 1);
        }
    }
}
